#!/usr/bin/env python
'''
A convenience class for handling countries data
It works as iterator
'''

class Country:
    countries = sorted(
            [   'Albania',
                'Armenia',
                'Argentina',
                'Australia',
                'Austria',
                'Belgium',
                'Brazil',
                'Bulgaria',
                'Canada',
                'Czech Republic',
                'Denmark',
                'France',
                'Germany',
                'Great Britain',
                'Greece',
                'Holland',
                'Hungary',
                'Iceland',
                'Ireland',
                'Italy',
                'Kazakhstan',
                'Lithuania',
                'Malta',
                'Mexico',
                'Monaco',
                'Netherlands',
                'Poland',
                'Portugal',
                'Romania',
                'Russia',
                'San Marino',
                'Scotland',
                'Slovakia',
                'Spain',
                'Sweden',
                'Turkey',
                'Ukraine',
                'U.S.A.',
                'Venezuela',
            ])
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    # |          keep in order!!!          |
    # *------------------------------------*

    def __init__(self, order):
        '''Take 'asc' or 'desc' as parameters'''

        self.index = 0
        if ((order.lower() != "asc") and (order.lower() != "desc")):
            raise TypeError
        self.order = order.lower()

    def __iter__(self):
        '''The iterator constructor'''
        return self

    def next(self):
        '''The next method for the iterator'''
        if self.index == len(self.countries):
            raise StopIteration
        self.index = self.index + 1
        if (self.order == "desc"):
            return self.countries.reverse()[self.index - 1]
        else:
            return self.countries[self.index - 1]


if __name__ == '__main__':
    for country in Country("asc"):
        print(country)
